<%@ page language="java" import="java.sql.*"%>
<html>
<head><title>Read from mySQL Database</title>
</head>
<body>
<center>
<p><font color="#0080FF" size="18">Delete Presentation Page</font></p>

<table border="1">
<tr>
<th>User Name</th>
<th>File Name</th>
<th>Delete</th>
</tr>

<%

       try
       {
		if(session.getAttribute("logged_in") == "true")
		{
			out.println("<p><h2>Logged In</p></h2>");
			if(session.getAttribute("user_level") == "administrator")
			{
				String DRIVER = "com.mysql.jdbc.Driver";
				Class.forName(DRIVER);

				Connection con=null;
				ResultSet rst=null;
				PreparedStatement stmt=null;
				ResultSet rstQuery=null;
				PreparedStatement  stmtQuery=null;

				String url="jdbc:mysql://ecstiger.cs.andrews.edu/d562_2010_01?user=u562_2010_01&password=YPJ8f4We";
				con=DriverManager.getConnection(url);

				stmt = con.prepareStatement("SELECT * FROM presentation;");
				rst=stmt.executeQuery();
				
				
				while(rst.next())
				{

					int ID = rst.getInt("id");
					String FileName = rst.getString("file_name");
					int UserId = rst.getInt("user_id");

					PreparedStatement stmtQuery = con.prepareStatement("SELECT * FROM user WHERE id = '" + UserId + "';");
					rstQuery=stmtQuery.executeQuery(); 
					rstQuery.next();
					String UserName = rstQuery.getString(3);

					%>
					<tr>
					<td><% out.println(UserName); %></td>
					<td><% out.println(FileName); %></td>	
					<td><FORM ACTION=delete_presentation_exec.jsp METHOD=POST><input type="radio" name="id" value="<% out.println(ID);%>" /></td>
					</tr>
					<%

				}

				%>
				</table>
				<br>
				<input type="submit" value="Confirm" /></FORM>
				<br><br>
				<a href=menu.jsp>Main Menu</a>
			<%
			rst.close();
			stmt.close();
			con.close();
			}
		}
		else
		{
			out.println("Not Logged In");
		}
	}
	catch(Exception e)
	{
		out.println(e);
	}

			
	

%>

</center>
</body>

</center>
</div>


</body>
</html>
